//
//   Copyright 2011 Gynvael Coldwind & Mateusz "j00ru" Jurczyk
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdint.h>
#include "object.h"
#include "global.h"
using namespace std;

void object_Insert(OBJECT_STRUCT* object)
{
  OBJECT_STRUCT* obj = new OBJECT_STRUCT;
  if(obj == NULL)
    return;

  memcpy(obj, object, sizeof(OBJECT_STRUCT));
  g_Objects.push_back(obj);
}

OBJECT_STRUCT* object_CreateBullet(float x, float y, int map_id, float vx, float vy)
{
  OBJECT_STRUCT* object = new OBJECT_STRUCT;
  if(object == NULL) // highly unlikely
    return NULL;

  object->type = OBJECT_TYPE_SPELL_BULLET;
  object->x = x;
  object->y = y;
  object->map_id = map_id;
  object->w = 0.8f;
  object->h = 0.8f;

  // Bullet speed = 8

  object->u.spellFireball.vx = vx * 10.0f;
  object->u.spellFireball.vy = vy * 10.0f;

  g_Objects.push_back(object);

  return object;
}

OBJECT_STRUCT* object_CreateFireball(float x, float y, int map_id, float vx, float vy)
{
  OBJECT_STRUCT* object = new OBJECT_STRUCT;
  if(object == NULL) // highly unlikely
    return NULL;

  object->type = OBJECT_TYPE_SPELL_FIREBALL;
  object->x = x;
  object->y = y;
  object->map_id = map_id;
  object->w = 0.8f;
  object->h = 0.8f;

  // Fireball speed = 10

  object->u.spellFireball.vx = vx * 12.0f;
  object->u.spellFireball.vy = vy * 12.0f;

  g_Objects.push_back(object);

  return object;
}

